package com.bigscreen.dao.Impl;

import com.bd1904.db.JedisUtil;
import com.bigscreen.dao.ShopRankDao;
import org.springframework.stereotype.Repository;
import redis.clients.jedis.Jedis;

import java.util.Set;

@Repository
public class ShopRankDaoImpl implements ShopRankDao {
    @Override
    public Set<String> zrange(String key, int start, int end) {
        Jedis jedis = JedisUtil.getJedis();
        Set<String> members = jedis.zrange(key,start,end);
        JedisUtil.release(jedis);

        return members;
    }

    @Override
    public Long length(String key) {
        Jedis jedis = JedisUtil.getJedis();
        Long len = jedis.zcard(key);
        JedisUtil.release(jedis);
        return len;
    }

    @Override
    public Double score(String key, String memeber) {
        Jedis jedis = JedisUtil.getJedis();
        Double zscore = jedis.zscore(key, memeber);
        JedisUtil.release(jedis);
        return zscore;
    }
}
